package com.wd.tw.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wd.tw.domain.entity.ElevatorCameraSignal;
import com.wd.tw.service.ElevatorCameraSignalService;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wd.common.core.controller.BaseController;
import com.wd.common.core.domain.HttpResponse;
import com.wd.common.annotation.Log;
import com.wd.common.enums.BusinessType;
import com.wd.common.utils.poi.ExcelUtil;


/**
 * 相机信号映射Controller
 * 
 * @author liumingkun
 * @date 2025-01-07
 */
@RestController
@RequestMapping("/business/signal")
public class ElevatorCameraSignalController extends BaseController
{
    @Resource
    private ElevatorCameraSignalService elevatorCameraSignalService;

    /**
     * 查询相机信号映射列表
     */
    @PreAuthorize("@ss.hasPermi('business:signal:list')")
    @GetMapping("/list")
    public HttpResponse list(ElevatorCameraSignal elevatorCameraSignal)
    {
        startPage();
        List<ElevatorCameraSignal> list = elevatorCameraSignalService.selectElevatorCameraSignalList(elevatorCameraSignal);
        return HttpResponse.successData(getDataTable(list));
    }

    /**
     * 导出相机信号映射列表
     */
    @PreAuthorize("@ss.hasPermi('business:signal:export')")
    @Log(title = "相机信号映射", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElevatorCameraSignal elevatorCameraSignal)
    {
        List<ElevatorCameraSignal> list = elevatorCameraSignalService.selectElevatorCameraSignalList(elevatorCameraSignal);
        ExcelUtil<ElevatorCameraSignal> util = new ExcelUtil<ElevatorCameraSignal>(ElevatorCameraSignal.class);
        util.exportExcel(response, list, "相机信号映射数据");
    }

    /**
     * 获取相机信号映射详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:signal:query')")
    @GetMapping(value = "/{cameraSignalId}")
    public HttpResponse getInfo(@PathVariable("cameraSignalId") Long cameraSignalId)
    {
        return successData(elevatorCameraSignalService.selectElevatorCameraSignalByCameraSignalId(cameraSignalId));
    }

    /**
     * 新增相机信号映射
     */
    @PreAuthorize("@ss.hasPermi('business:signal:add')")
    @Log(title = "相机信号映射", businessType = BusinessType.INSERT)
    @PostMapping
    public HttpResponse add(@RequestBody ElevatorCameraSignal elevatorCameraSignal)
    {
        return getResult(elevatorCameraSignalService.insertElevatorCameraSignal(elevatorCameraSignal));
    }

    /**
     * 修改相机信号映射
     */
    @PreAuthorize("@ss.hasPermi('business:signal:edit')")
    @Log(title = "相机信号映射", businessType = BusinessType.UPDATE)
    @PutMapping
    public HttpResponse edit(@RequestBody ElevatorCameraSignal elevatorCameraSignal)
    {
        return getResult(elevatorCameraSignalService.updateElevatorCameraSignal(elevatorCameraSignal));
    }

    /**
     * 删除相机信号映射
     */
    @PreAuthorize("@ss.hasPermi('business:signal:remove')")
    @Log(title = "相机信号映射", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cameraSignalIds}")
    public HttpResponse remove(@PathVariable Long[] cameraSignalIds)
    {
        return getResult(elevatorCameraSignalService.deleteElevatorCameraSignalByCameraSignalIds(cameraSignalIds));
    }
}
